<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>情感分析工具</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" rel="stylesheet">
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f8f9fa;
            color: #333;
        }
        .container {
            max-width: 1200px;
            margin-top: 50px;
        }
        .card {
            border: none;
            border-radius: 15px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
        }
        .card-header {
            background-color: #007bff;
            color: white;
            border-radius: 15px 15px 0 0 !important;
            padding: 20px;
        }
        .card-body {
            padding: 30px;
        }
        .btn-primary {
            background-color: #007bff;
            border: none;
            border-radius: 30px;
            padding: 10px 20px;
            font-weight: bold;
            transition: all 0.3s ease;
        }
        .btn-primary:hover {
            background-color: #0056b3;
            transform: scale(1.05);
        }
        .form-control {
            border-radius: 10px;
        }
        .alert {
            border-radius: 10px;
        }
        .file-upload-wrapper {
            position: relative;
            width: 100%;
            height: 60px;
            border: 2px dashed #007bff;
            border-radius: 10px;
            display: flex;
            justify-content: center;
            align-items: center;
            overflow: hidden;
        }
        .file-upload-wrapper input[type=file] {
            position: absolute;
            left: 0;
            top: 0;
            opacity: 0;
            width: 100%;
            height: 100%;
            cursor: pointer;
        }
        .file-upload-text {
            color: #007bff;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1 class="text-center mb-5">情感分析工具</h1>
        <div class="row">
            <div class="col-md-6 mb-4">
                <div class="card h-100">
                    <div class="card-header">
                        <h2 class="mb-0"><i class="fas fa-comment-alt me-2"></i>单条文本分析</h2>
                    </div>
                    <div class="card-body">
                        <form method="post">
                            <div class="mb-3">
                                <textarea class="form-control" name="text" rows="4" placeholder="请输入要分析的文本"></textarea>
                            </div>
                            <button type="submit" class="btn btn-primary w-100">
                                <i class="fas fa-search me-2"></i>分析
                            </button>
                        </form>
                        {% if result %}
                            <div class="mt-4 alert alert-info">
                                <h4 class="mb-0"><i class="fas fa-chart-bar me-2"></i>分析结果：{{ result }}</h4>
                            </div>
                        {% endif %}
                    </div>
                </div>
            </div>
            <div class="col-md-6 mb-4">
                <div class="card h-100">
                    <div class="card-header">
                        <h2 class="mb-0"><i class="fas fa-file-csv me-2"></i>批量CSV文件分析</h2>
                    </div>
                    <div class="card-body">
                        <form method="post" enctype="multipart/form-data">
                            <div class="mb-3">
                                <div class="file-upload-wrapper">
                                    <input type="file" class="form-control" name="file" accept=".csv" id="csv-file">
                                    <div class="file-upload-text">
                                        <i class="fas fa-cloud-upload-alt me-2"></i>选择CSV文件或拖放到这里
                                    </div>
                                </div>
                            </div>
                            <button type="submit" class="btn btn-primary w-100">
                                <i class="fas fa-upload me-2"></i>上传并分析
                            </button>
                        </form>
                        <div class="mt-4">
                            <p class="text-muted"><i class="fas fa-info-circle me-2"></i>请上传包含'text'列的CSV文件。分析结果将自动下载。</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        document.getElementById('csv-file').addEventListener('change', function(e) {
            var fileName = e.target.files[0].name;
            document.querySelector('.file-upload-text').innerHTML = '<i class="fas fa-file-csv me-2"></i>' + fileName;
        });
    </script>
</body>
</html>